package chainofResponsibilityPattern.handler.handler;

/**
 * Created by JiaJia on 2019/6/17 0017.
 */
public abstract class PriceHandler {
    protected PriceHandler successor; //指向自身的一个引用

    /**
     * 直接后继，用于传递请求
     * @param successor
     */
    public void setSuccessor(PriceHandler successor) {
        this.successor = successor;
    }

    /**
     * 处理折扣申请
     */

    public abstract void processDiscount(float discount);

    public static PriceHandler creatPriceHandler(){
        PriceHandler sales=new Sales();
        PriceHandler man=new Manager();
        PriceHandler dir=new Director();
        PriceHandler vp=new VicePresident();
        PriceHandler ceo=new CEO();

        sales.setSuccessor(man);
        man.setSuccessor(dir);
        dir.setSuccessor(vp);
        vp.setSuccessor(ceo);

        return sales;
    }
}